package com.wondream.rabbitmq.producer;

import com.wondream.rabbitmq.producer.config.RabbitmqConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author wondream
 * @version 1.0
 * @create 2022/5/8 5:57 PM
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class Producer05_topics_springboot {

    // 使用rabbitTemplate发送消息
    @Autowired
    RabbitTemplate rabbitTemplate;

    @Test
    public void testSendEmail(){
        String message = "send email message by springboot to user";
        /**
         * 参数
         * 1、交换机的名称
         * 2、路由key
         * 3、发送的消息
         */
        rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPIC_INFORM, "info.email", message);
    }
}
